Windows下用vs2017编译Thrift with C++

autoconfcmake系统构建工具,不需要指定库位置,这能够自动检测出很多系统的配置,然而如果你遇到问题或想让thrift链接到你自已的第三库:

1
2
- BOOST_ROOT : For boost, e.g. D:\boost_1_55_0 
- OPENSSL_ROOT_DIR : For OpenSSL, e.g. D:\OpenSSL-Win32

libthriftnb需要的库:

1
LIBEVENT_ROOT_DIR : For Libevent e.g. D:\libevent-2.0.21-stable

Linking Against Thrift

You need to link your project that uses thrift against all the thrift dependencies; in the case of libthrift, boost and for libthriftnb, libevent.
In the project properties you must also set HAVE_CONFIG_H as force include the config header: “windows/confg.h”

Dependencies

The same dependencies for shared_ptr as described above apply to windows as well.

boost thread http://www.boost.org/doc/libs/release/doc/html/thread.html

libevent (for libthriftnb only) http://monkey.org/~provos/libevent/

Notes on boost thread (static vs shared)
By default lib/cpp/windows/force_inc.h defines:

1
2
#define BOOST_ALL_NO_LIB 1
#define BOOST_THREAD_NO_LIB 1

命名管道(Named Pipes)

Named Pipe transport has been added in the TPipe and TPipeServer classes. This is currently Windows-only. Named pipe transport for NIX has not been
implemented. Domain sockets are a better choice for local IPC under non-Windows OS’s. NIX named pipes only support 1:1 client-server connection.

Thrift/SSL

1
2
mkdir cmake-build && cd cmake-build
cmake -G "Visual Studio 15 2017 Win64" -DBOOST_ROOT=D:/boost/boost_1_65_1 -DBUILD_PYTHON=OFF -DBUILD_CPP=ON -DWITH_SHARED_LIB=OFF -DBUILD_COMPILER=OFF -DBUILD_HASKELL=OFF ..